<?php
  $width = $_REQUEST['width'];
  if (!$width) {
    $width = 100;
  }
  $height = $_REQUEST['height'];
  if (!$height) {
    $height = 100;
  }
?>

		<script type="text/javascript">
			function insertArtSexyLightboxTag(editor)
			{
				var image = document.getElementById("image").value;
				var description = document.getElementById("description").value;
				var width = document.getElementById("width").value;
				var height = document.getElementById("height").value;
				
        if( image.substr(-4) === ".png"  ||
            image.substr(-4) === ".PNG"  ||
            image.substr(-4) === ".jpg"  ||
            image.substr(-4) === ".JPG"  ||
            image.substr(-5) === ".jpeg"  ||
            image.substr(-5) === ".JPEG"  ||
            image.substr(-4) === ".bmp"  ||
            image.substr(-4) === ".BMP"  ||
            image.substr(-4) === ".gif"  ||
            image.substr(-4) === ".GIF"  ||
            image.substr(-4) === ".png") {
            var pluginCode = '<a href="' + image + '" rel="sexylightbox" title="' + description + '"><img class="artsexylightbox" src="' + image + '" ';
          
            if (width) {
              pluginCode += 'width="' + width + '" ';
            }
            if (height) {
              pluginCode += 'height="' + height + '"';
            }
            pluginCode += '/></a>';
            pluginCode += '{artsexylightbox}{/artsexylightbox}';
        } else {
          var pluginCode = '{artsexylightbox path="' + image + '" ';
          if (width) {
            pluginCode += 'previewWidth="' + width + '" ';
          }
          if (height) {
            pluginCode += 'previewHeight="' + height + '"';
          }
          pluginCode += '}{/artsexylightbox}';
        }

				window.parent.jInsertEditorText(pluginCode, 'text');
				window.parent.document.getElementById('sbox-window').close();
				return false;
			}
		</script>

		<form>
    <b>Art Sexy Lightbox Properties</b>
    <br /><br />
		<table width="100%" align="center">
			<tr>
				<td class="key" align="right" width="20%">
					<label for="title">
						Image
					</label>
				</td>
				<td>
          <div style="float:left;margin-left: 15px">
            <input type="text" id="image" name="image" value="images/" size="45"/>
          </div>
          <div style="float:left;margin-left: 15px">
            <b>Example:</b>images/image1.jpg or images/stories
          </div>
				</td>
			</tr>
			<tr>
				<td class="key" align="right"  width="20%">
					<label for="title">
						Description
					</label>
				</td>
				<td>
          <div style="float:left;margin-left: 15px">
            <input type="text" id="description" name="description" value="" size="45"/>
          </div>
          <div style="float:left;margin-left: 15px">
            <b>Example:</b>my image
          </div>
				</td>
			</tr>
      <tr>
				<td class="key" align="right" width="20%">
					<label for="title">
						Width
					</label>
				</td>
				<td>
          <div style="float:left;margin-left: 15px">
            <input type="text" id="width" name="width" value="<?php echo $width; ?>" size="45"/>
          </div>
				</td>
			</tr>
      <tr>
				<td class="key" align="right" width="20%">
					<label for="title">
						Height
					</label>
				</td>
				<td>
          <div style="float:left;margin-left: 15px">
            <input type="text" id="height" name="height" value="<?php echo $height; ?>" size="45"/>
          </div>
				</td>
			</tr>
      <tr>
        <td colspan="2" align="right">
          <button onclick="insertArtSexyLightboxTag();">ok</button> 
        </td>
      </tr>
		</table>
		</form>